<html>
<head>
	<title>正在连接...</title>
</head>
<body></body>
</html>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
	function getUrlParams(url) {
      let urlinfo = url.split('?');
      if(urlinfo.length == 1) return {};
      const paramsArray = url.split('?')[1].split('&');
      const params = paramsArray.reduce((acc, param) => {
        const [key, value] = param.split('=');
        acc[key] = value;
        return acc;
      }, {});
      return params;
    }
    let params = getUrlParams(location.href)
    let url = "https://chinabp-itg.ext.hp.com.cn/uam/oauth2/authorization?appCode=MPS-FEC&redirectUrl=https://chinabp-itg.ext.hp.com.cn/fec-api/api/cbpOauthIOS.html";

    if(!params.code){
        location.href=url;
    }else{

        $.ajax({
            type: "POST",
            data:JSON.stringify({"code":params.code}),
            url: "https://chinabp-itg.ext.hp.com.cn/fec-api/api/login",
            contentType:'application/json',
            success:function(data){
                //debugger;
                sessionStorage.setItem('username',data.email);
                sessionStorage.setItem('type',0);
                sessionStorage.setItem('token',data.token);
                localStorage.setItem('username',data.email);
                localStorage.setItem('type',0);
                localStorage.setItem('token',data.token);
                location.href="https://chinabp-itg.ext.hp.com.cn/fec-api/frui/hpfecios/index.html?username="+data.email+'&token='+data.token+'&type='+0+"#/choose";
            }
        });

    }


</script>